package com.wx.day04.aop01.Calculateimpl;

import com.wx.day04.aop01.Calculate;

public class CalculateProxy implements Calculate {
    private Calculateimpl target;
    public CalculateProxy(Calculateimpl target) {
        this.target = target;
    }
    @Override
    public Integer divide(int a, int b) {
        System.out.println("开启事务");
        int res = target.divide(a, b);
        System.out.println("提交事务");
        return res;
    }

    @Override
    public Integer multiply(int a, int b) {
        System.out.println("开启事务");
        int res = target.multiply(a, b);
        System.out.println("提交事务");
        return res;
    }

    @Override
    public Integer subtract(int a, int b) {
        System.out.println("开启事务");
        int res = target.subtract(a, b);
        System.out.println("提交事务");
        return res;
    }

    @Override
    public Integer add(int a, int b) {
        System.out.println("开启事务");
        int res = target.add(a, b);
        System.out.println("提交事务");
        return res;
    }
}
